package com.lz.hrmanager.controller;

import com.lz.hrmanager.entity.Account;
import com.lz.hrmanager.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("account")
public class AccountController {

    @Autowired
    private AccountService accountService;

    @RequestMapping("/list")
    public String getAccountById(ModelMap modelMap){
        System.out.println("控制层");
        System.out.println(accountService.getAll().size());
        modelMap.addAttribute("accounts",accountService.getAll());
        return "account/list";
    }

    //新增和编辑
    @ResponseBody
    @RequestMapping("save")
    public String save(@ModelAttribute Account account){

            account = new Account("1002","1","李四","4000","342345895463","lisi@qq.com","14924422157","财务部",null,null,null,null,null,"500","0","3500");
            accountService.add(account);
        return "success";
    }

}
